package com.share.bean.oa.org;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
 * 说明：
 * OA-部门
 * <br/>作者：杨浩泉
 * <br/>日期：2010-5-1
 */  
@Entity
@Table(name="share_oa_department")
public class Department {
	 
	/** 部门编号,主键,12位 */
	private String deptNo ;
	
	/** 部门名称 */
	private String deptName ;
	
	/** 部门负责人 */
	private String deptContactPeople ;
	
	/** 部门联系电话 */
	private String deptContactTel ;
	
	/** 部门信息 */
	private String deptMsg ;
	
	/** 部门备注 */
	private String deptBak ;
	
	/** 部门创建时间 */
	private Date deptCreTime ;
	
	private Set<Department> deptChild ;
	
	private Department deptParent ;
	
	@ManyToOne
	@JoinColumn(name="sdeptno")
	public Department getDeptParent() {
		return deptParent;
	}

	public void setDeptParent(Department deptParent) {
		this.deptParent = deptParent;
	}

	@OneToMany(mappedBy="deptParent")
	@JoinColumn(name="sdeptno")
	public Set<Department> getDeptChild() {
		return deptChild;
	}

	public void setDeptChild(Set<Department> deptChild) {
		this.deptChild = deptChild;
	}


	/** 部门与机构多对一关系 */
	private Organization organization ;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="org_code")
	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	/** 部门与员工一对多关系，维护端为员工 */
	private Set<Employee> employee = new HashSet<Employee>();

	@OneToMany(mappedBy="department",cascade=CascadeType.REFRESH)
	@JoinColumn(name="dept_id")
	public Set<Employee> getEmployee() {
		return employee;
	}

	public void setEmployee(Set<Employee> employee) {
		this.employee = employee;
	}

	@Id @Column(length=12,nullable=false)
	public String getDeptNo() {
		return deptNo;
	}

	public void setDeptNo(String deptNo) {
		this.deptNo = deptNo;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public String getDeptContactPeople() {
		return deptContactPeople;
	}

	public void setDeptContactPeople(String deptContactPeople) {
		this.deptContactPeople = deptContactPeople;
	}

	public String getDeptContactTel() {
		return deptContactTel;
	}

	public void setDeptContactTel(String deptContactTel) {
		this.deptContactTel = deptContactTel;
	}

	public String getDeptMsg() {
		return deptMsg;
	}

	public void setDeptMsg(String deptMsg) {
		this.deptMsg = deptMsg;
	}

	public String getDeptBak() {
		return deptBak;
	}

	public void setDeptBak(String deptBak) {
		this.deptBak = deptBak;
	}

	@Temporal(TemporalType.DATE)
	public Date getDeptCreTime() {
		return deptCreTime;
	}

	public void setDeptCreTime(Date deptCreTime) {
		this.deptCreTime = deptCreTime;
	}
}
